﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Lottery
{
    public partial class DisplayForm : Form
    {
        private string major;
        private string person;
        private System.Timers.Timer timer;

        public DisplayForm(string major, string person)
        {
            this.major = major;
            this.person = person;

            InitializeComponent();
        }

        private void TimerHandle(object o, System.Timers.ElapsedEventArgs e)
        {
            timer.Stop();
            this.Close();
        }

        private void DisplayForm_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

            timer = new System.Timers.Timer(2000);
            timer.Elapsed += new System.Timers.ElapsedEventHandler(TimerHandle);
            timer.Start();

            this.WindowState = FormWindowState.Maximized;
            this.label1.Text = this.major;
            this.label2.Text = this.person;

            this.label3.Left = (this.Width - this.label3.Width) / 2;

            this.pictureBox1.Left = this.Width / 2 + 50;
            this.pictureBox1.Top = (this.Height - this.pictureBox1.Height) / 2;
            this.pictureBox1.Image = System.Drawing.Image.FromFile(@"photo\" + major + "_" + person + "_大小.jpg");
            
            this.label1.Left = this.Width / 2 - 200 - this.label1.Width;
            this.label1.Top = this.Height / 2 - this.label1.Height - 10;

            this.label2.Left = this.Width / 2 - 200 - this.label2.Width;
            this.label2.Top = this.Height / 2 + this.label2.Height + 10;
        }

        private void DisplayForm_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Return)
            {
                this.Close();
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
